package com.googlecode.etrade.client;

import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.data.BeanModel;
import com.extjs.gxt.ui.client.data.ListLoader;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.util.Theme;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.googlecode.etrade.client.acaotab.AcoesTab;
import com.googlecode.etrade.client.ncortab.NCorretagemTab;

/**
 * A classe ETrade &eacute; o EntryPoint da aplica&ccedil;&atilde;o.
 * 
 * @author Rafael Freitas
 * @version 1.0
 */
public class ETrade implements EntryPoint {

	private ListLoader<BeanModel> loader;

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		GXT.setDefaultTheme(Theme.BLUE, true);

		TabPanel tabPanel = new TabPanel();
		tabPanel.setAutoWidth(true);

		TabItem acoes = new TabItem("Ações");
		acoes.addStyleName("pad-text");

		Viewport viewport = new Viewport();
		
		// configurando Tab Acoes
		BorderLayoutData outCenter = new BorderLayoutData(LayoutRegion.CENTER);
		outCenter.setMargins(new Margins(5));
		viewport.setLayout(new BorderLayout());
		
		viewport.add(new AcoesTab(), outCenter);
		
		acoes.add(viewport);
		
		TabItem nCorretagem = new TabItem("Notas de Corretagem");
		nCorretagem.addStyleName("pad-text");
		
		Viewport vpNCorr = new Viewport();
		vpNCorr.setLayout(new BorderLayout());
		vpNCorr.add(new NCorretagemTab(), outCenter);
		
		nCorretagem.add(vpNCorr);
		
		tabPanel.add(acoes);
		tabPanel.add(nCorretagem);

		RootPanel.get().add(new HeadApp());
		RootPanel.get().add(tabPanel);
		GXT.hideLoadingPanel("loading");

		loader.load();
	}
}